package com.cloudfast.context.error;

import org.springframework.http.HttpStatus;

/**
 * 异常枚举类型
 *
 * @author liuyw
 * @date 2022年8月29日
 */
public enum ErrorCode {

    /**
     * 用户名密码错误
     */
    USERNAME_PASSWORD_ERROR(1001, "用户名或密码错误","用户名或密码错误", HttpStatus.UNAUTHORIZED),
    /**
     * 用户名不存在
     */
    NO_USERNAME_INFO(1002, "用户名不存在", "用户名不存在",HttpStatus.INTERNAL_SERVER_ERROR),
    /**
     * 重复登入
     */
    RE_LOGIN(1003, "该用户已登入,请勿重复登入", "该用户已登入,请勿重复登入.",HttpStatus.FORBIDDEN),
    /**
     * 手机号码不存在
     */
    NO_PHONE_NUM(1004, "手机号码不存在", "手机号码不存在",HttpStatus.UNAUTHORIZED),
    /**
     * 密码解析异常
     */
    PASSWORD_PARSE_ERROR(1005, "未加密的认证信息","未加密的认证信息", HttpStatus.UNAUTHORIZED),
    /**
     * 第三方认证ticket为空
     */
    TICKET_NULL(1006, "第三方认证ticket为空", "第三方认证ticket为空",HttpStatus.UNAUTHORIZED),
    /**
     * 获取钉钉用户信息异常
     */
    GET_DING_TALK_USER_ERROR(1007, "获取钉钉用户信息异常","获取钉钉用户信息异常", HttpStatus.UNAUTHORIZED),
    /**
     * 第三方认证ticket为空
     */
    NO_TICKET_SYSTEM_ERROR(1008, "第三方认证异常", "第三方认证异常",HttpStatus.UNAUTHORIZED),

    /**
     * 未定义的APP信息
     */
    NO_UNDEFINED_APP_INFO(1009, "未关联到APP信息","未关联到APP信息", HttpStatus.UNAUTHORIZED),

    /**
     * 未关联到用户信息
     */
    NO_USER_INFO(1010, "未关联到用户信息","未关联到用户信息", HttpStatus.UNAUTHORIZED),

    /**
     * 密码错误超限,已被锁定!
     */
    PASSWORD_ERROR_LOCK(1011, "密码错误次数超限,已被锁定!","密码错误次数超限,已被锁定!", HttpStatus.FORBIDDEN),

    /**
     * 认证失败,您的账号将在失败%s次后被锁定!
     */
    PASSWORD_ERROR_COUNT(1012, "","认证失败,失败%s次后将被锁定!", HttpStatus.FORBIDDEN),

    /**
     * 客户端异常
     */
    CLIENT_ERROR(1101, "未识别的客户端","未识别的客户端", HttpStatus.UNAUTHORIZED),

    /**
     * 授权模式异常
     */
    GRANT_TYPE_ERROR(1102, "未识别的授权模式", "未识别的授权模式",HttpStatus.UNAUTHORIZED),
    /**
     * token异常
     */
    NO_TOKEN_ERROR(1103, "TOKEN异常,请重新登入", "TOKEN异常,请重新登入",HttpStatus.UNAUTHORIZED),
    /**
     * token已失效
     */
    TOKEN_VALID_ERROR(1104, "TOKEN已失效,请重新登入","TOKEN已失效,请重新登入", HttpStatus.UNAUTHORIZED),
    /**
     * 授权异常
     */
    AUTHORIZATION_ERROR(1105, "授权异常,请联系管理员","授权异常,请联系管理员.", HttpStatus.UNAUTHORIZED),
    /**
     * scope范围异常
     */
    SCOPE_ERROR(1106, "资源访问范围异常","资源访问范围异常", HttpStatus.UNAUTHORIZED),
    /**
     * 无实现方法
     */
    NO_IMPL_METHOD(1201, "请重定义该方法", "请重定义该方法",HttpStatus.NOT_FOUND),

    /**
     * 短信验证码为空
     */
    NO_SMS_CODE(1301, "短信验证码为空", "短信验证码为空",HttpStatus.UNAUTHORIZED),

    /**
     * 短信验证码错误
     */
    SMS_CODE_ERROR(1303, "无效短信验证码", "无效短信验证码",HttpStatus.UNAUTHORIZED),

    /**
     * 短信验证码在有效范围内
     */
    SMS_CODE_TIME_OUT(1302, "短信验证码在有效范围内","短信验证码在有效范围内", HttpStatus.UNAUTHORIZED),

    /**
     * 不支持的请求方法
     */
    METHOD_NOT_SUPPORTED(1401, "不支持的请求方法", "不支持的请求方法",HttpStatus.NOT_FOUND),

    /**
     * 验证码错误
     */
    CAPTCHA_CODE_ERROR(1402, "验证码错误", "验证码错误",HttpStatus.UNAUTHORIZED),

    /**
     * 查询出多条记录
     */
    DATA_MORE(1403, "查询出多条记录", "查询出多条记录",HttpStatus.INTERNAL_SERVER_ERROR),
    /**
     * 没有访问权限
     */
    NO_AUTH(1404, "无访问权限", "无访问权限",HttpStatus.UNAUTHORIZED),

    /**
     * 根据id查询异常
     */
    FIND_ONE_ERROR(5001, "主键查询异常","主键查询异常", HttpStatus.INTERNAL_SERVER_ERROR),

    /**
     * insert 异常
     */
    SAVE_ERROR(5002, "保存操作异常", "保存操作异常",HttpStatus.INTERNAL_SERVER_ERROR),
    /**
     * 分页 异常
     */
    FIND_PAGE_ERROR(5003, "分页查询异常", "分页查询异常",HttpStatus.INTERNAL_SERVER_ERROR),
    /**
     * 分页 异常
     */
    DELETE_ERROR(5004, "删除异常","删除异常", HttpStatus.INTERNAL_SERVER_ERROR),
    /**
     * 分页 异常
     */
    DELETE_ROLE_HAS_USER(5005, "角色含有用户无法删除","角色含有用户无法删除", HttpStatus.INTERNAL_SERVER_ERROR),

    /**
     * 自定义异常
     */
    CUSTOM_ERROR(6666, "", "%s",HttpStatus.INTERNAL_SERVER_ERROR),

    /**
     * 系统内部异常
     */
    SYSTEM_ERROR(5000, "操作异常,请查看日志", "操作异常,请查看日志",HttpStatus.INTERNAL_SERVER_ERROR);

    private int code;

    private String msg;

    private String defaultMsg;

    private HttpStatus httpStatus;

    ErrorCode(int code, String msg,String defaultMsg, HttpStatus httpStatus) {
        this.code = code;
        this.msg = msg;
        this.httpStatus = httpStatus;
        this.defaultMsg=defaultMsg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public HttpStatus getHttpStatus() {
        return httpStatus;
    }

    public void setHttpStatus(HttpStatus httpStatus) {
        this.httpStatus = httpStatus;
    }

    public String getDefaultMsg() {
        return defaultMsg;
    }

    public void setDefaultMsg(String defaultMsg) {
        this.defaultMsg = defaultMsg;
    }
}
